using Microsoft.AspNetCore.Mvc;
using Wordss.Models;
using Wordss.Dto;
using Wordss.Hickey;

namespace Wordss.Conterllers;
[ApiController]
[Route("api/[controller]")]
public class UseConterlles : ControllerBase{
private readonly IDtojs<Blog> _blogRe;
public UseConterlles(IDtojs<Blog> blogRe)
{
  _blogRe=blogRe;
}
[HttpGet]

public async Task<IActionResult> Get(){
    var List =await _blogRe.GetAll();
    return Ok(List);
} 



[HttpPost]

public async Task<IActionResult> Post (UserCrea userCrea){
    var obj =new Blog{Name=userCrea.Name,Age=userCrea.Age};
    await _blogRe.PastAsync(obj);

    return Ok(obj);
}




[HttpPut("{id}")]

public async Task<IActionResult> Put(Guid id,UserCrea userCrea){
    var obj = await _blogRe.GetByAll(id);
    if(obj==null){
        return NotFound();
    }
    obj.Name =userCrea.Name;
    obj.Age=userCrea.Age;
    await _blogRe.PutAsync(obj);
    return NotFound();

}


[HttpDelete("{id}")]

public async Task<IActionResult> Delete(Guid id)
{
    var obj =await _blogRe.GetByAll(id);
    if (obj==null){
        return NotFound();
    }
    await _blogRe.DelAsync(obj);

    return NotFound();
        
    
}

}

